package com.ruoyi.web.controller.member;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.member.domain.MemberInfoTable;
import com.ruoyi.member.service.IMemberInfoTableService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 桃丽丝研究所成员信息Controller
 *
 * @author Marissa
 * @date 2023-12-05
 */
@RestController
@RequestMapping("/member/table")
public class MemberInfoTableController extends BaseController {
    @Autowired
    private IMemberInfoTableService memberInfoTableService;

    /**
     * 查询桃丽丝研究所成员信息列表
     */
    @PreAuthorize("@ss.hasPermi('member:table:list')")
    @GetMapping("/list")
    public TableDataInfo list(MemberInfoTable memberInfoTable) {
        startPage();
        List<MemberInfoTable> list = memberInfoTableService.selectMemberInfoTableList(memberInfoTable);
        return getDataTable(list);
    }

    /**
     * 导出桃丽丝研究所成员信息列表
     */
    @PreAuthorize("@ss.hasPermi('member:table:export')")
    @Log(title = "桃丽丝研究所成员信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MemberInfoTable memberInfoTable) {
        List<MemberInfoTable> list = memberInfoTableService.selectMemberInfoTableList(memberInfoTable);
        ExcelUtil<MemberInfoTable> util = new ExcelUtil<MemberInfoTable>(MemberInfoTable.class);
        util.exportExcel(response, list, "桃丽丝研究所成员信息数据");
    }

    /**
     * 获取桃丽丝研究所成员信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('member:table:query')")
    @GetMapping(value = "/{memberId}")
    public AjaxResult getInfo(@PathVariable("memberId") Long memberId) {
        return success(memberInfoTableService.selectMemberInfoTableByMemberId(memberId));
    }

    /**
     * 新增桃丽丝研究所成员信息
     */
    @PreAuthorize("@ss.hasPermi('member:table:add')")
    @Log(title = "桃丽丝研究所成员信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MemberInfoTable memberInfoTable) {
        return toAjax(memberInfoTableService.insertMemberInfoTable(memberInfoTable));
    }

    /**
     * 修改桃丽丝研究所成员信息
     */
    @PreAuthorize("@ss.hasPermi('member:table:edit')")
    @Log(title = "桃丽丝研究所成员信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MemberInfoTable memberInfoTable) {
        return toAjax(memberInfoTableService.updateMemberInfoTable(memberInfoTable));
    }

    /**
     * 删除桃丽丝研究所成员信息
     */
    @PreAuthorize("@ss.hasPermi('member:table:remove')")
    @Log(title = "桃丽丝研究所成员信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{memberIds}")
    public AjaxResult remove(@PathVariable Long[] memberIds) {
        return toAjax(memberInfoTableService.deleteMemberInfoTableByMemberIds(memberIds));
    }
}
